package com.emip.util.report.impl;

import java.math.BigDecimal;
import java.text.DecimalFormat;

import org.springframework.stereotype.Component;

import com.emip.bean.Store;
import com.emip.util.report.Comput;

@Component
public class MinComput extends Comput {

	private BigDecimal min ;
	
	public MinComput() {}
	
	@Override
	public void appendData(Store store) {
		if (count == 1) this.min = new BigDecimal(store.getValue());
		else {
			BigDecimal value = new BigDecimal(store.getValue());
			if (this.min.compareTo(value) > 0) this.min = value;
		}
	}

	public String getResult() {
		if (count == 0) return "";
		DecimalFormat df = new DecimalFormat("#.###");
		return df.format(min);
	}

	public Comput newInstance() {
		return new MinComput();
	}

	public String getLabel() {
		return "最小值";
	}

}
